<%@ page language="java"  contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
</head>
<body bgcolor="#cccccc" style="text-align:center;margin-top:100px;">

<%

java.sql.Connection conn=null;
java.sql.PreparedStatement prepared=null;
java.sql.ResultSet set= null;
 
try{
Class.forName("com.mysql.jdbc.Driver");
conn=java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/school1130","root","root");
prepared= conn.prepareStatement("select account,count(*) from post group by account  order by count(*) desc");
set = prepared.executeQuery();
String account;
String count;
out.print("<font style=' font-size:45px;letter-spacing:20px;'>用户发帖量统计</font>");
out.print("<table border='solid,1px' style='margin-left:500px;margin-top:60px;width:300px;height:30px;border-style:solid 1px;'>");
 out.print("<tr><td>账户</td><td>发帖数量</td></tr>");
while(set.next()){
	out.print("<tr>");
	out.print("<td>");
	account  = set.getString("account");
	out.print(account+"</td>");
	out.print("<td>");
	count = set.getString(2);
	System.out.println(account+"     "+count);
    out.print(count+"</td>");
    out.print("</tr>");
}
out.print("</table");
}catch(Exception e){
	  e.printStackTrace();
}finally{
	
	set.close();
	prepared.close();
	conn.close();
}

%>

</body>
</html>